Executing Commands

To provide the ability to execute commands to compile or build and even control a remote debugger, Programmer Studio uses the TELNET protocol to create a remote VT (virtual terminal) session on the server. Once successfully authenticated as a user, the command prompt provides access to all the functionality Programmer Studio requires.

What is TELNET

TELNET is the main Internet protocol for creating a connection with a remote machine. It gives the user the opportunity to be on one computer system and do work on another, which may be across the street or thousands of miles away.

Authentication

Unfortunately, unlike the agreed format of the TELNET protocol, the interaction between the user and the remote machine are undefined once a connection has been established. Typically, following a connection, the remote server will prompt for the user to authenticate themselves which usually takes the form of a user name and password.

As these authentication prompts differ drastically between servers, Programmer Studio requires each server profile to determine the text of each prompt expected, and then the desired response. You can also specify which responses the user should be prompted for during the login process.

Detecting the Command Prompt

Just as with initial authentication, following a successful login, the format of the command prompt displayed to the user can also change dramatically between servers. Detection of the command prompt is perhaps the most vital part of any server profile; this is used to determine that each command executed has been completed and the server is æreadyÆ for the next command.

Using Regular Expressions

Just as with the DOS prompt, most server operating systems provide the facility to create a dynamic command prompt. This may display the current user name, date, time or the current working directory. To detect such unpredictable text, regular expressions are used to identify the pattern of a prompt, the components which remain constant and the format of those which change.

Take the following command prompt for example:

130[/home/greg]$

This command prompt displays the command index (the number of commands executed by this user), the current working directory and some constraining characters for readability.

This can be described using the following regular expression:

[0-9]+\[.*\]\$

This regular expression describes the variable components of the command prompt as a ôranges of digitsö and ôall characters up toàö while including the static characters, ô[ô, ô]ö and ô$ö.

Note As the characters, ô[ö, ô]ö and ô$ö, are special regular expression format variables, the back-slash character is prefixed to determine the characters should be matched literally.

Using regular expressions it then becomes possible to detect the command prompt regardless of what the result of a command may be. The obvious exception to this however is if the prompt should be changed dramatically.

Changing the Command Prompt

There will be situations when the format of the command prompt is so simple that it can not be adequately identified from other output normally appearing in command output. In these situations a server profile can be configured to execute a command following successful authentication which changes the format of the prompt.

Session Wizard

Obviously specifying the correct format for prompts and responses during authentication and then creating an expression to detecting the command prompt is a complex task.

To help, Programmer Studio provides a Session Wizard. The session wizard creates a TELNET session on the server and displays the text received in order for the user to easily determine what constitutes a prompt and what the correct response is. Once authenticated, the session wizard attempts to determine if the server uses a variable prompt and, if so, helps create a regular expression.

The session wizard may be run separately or as part of the Add Server Wizard.